<template>
  <!-- 添加或修改对话框 -->
  <el-dialog title="编辑" :visible.sync="dialogFormVisible" width="600px"
    :close-on-click-modal="false">
    <el-form ref="dataForm" :rules="rules" :model="dataForm" status-icon label-position="left" label-width="100px"
      style="width: 80%; margin-left:50px;">
      <el-form-item label="学员类型" prop="studentsType" v-if="selectTF">
        <el-select v-model="dataForm.studentsType" @change="selectItem" clearable placeholder="请选择">
          <el-option :value="1" label="主要负责人" />
          <el-option :value="2" label="管理人员" />
          <el-option :value="3" label="从业人员" />
        </el-select>
      </el-form-item>
      <el-form-item label="课程类型" prop="courseType" v-if="selectTF">
        <el-select v-model="dataForm.courseType" clearable placeholder="请选择">
          <el-option :value="1" v-show="dataForm.studentsType==1" label="主要负责人新取证" />
          <el-option :value="2" v-show="dataForm.studentsType==1" label="主要负责人继续教育" />
          <el-option :value="3" v-show="dataForm.studentsType==2" label="管理人员新取证" />
          <el-option :value="4" v-show="dataForm.studentsType==2" label="管理人员继续教育" />
          <el-option :value="5" v-show="dataForm.studentsType==3" label="从业人员新取证" />
          <el-option :value="6" v-show="dataForm.studentsType==3" label="从业人员继续教育" />
        </el-select>
      </el-form-item>
      <el-form-item label="学员类型" prop="studentsType" v-if="!selectTF">
        <el-select v-model="dataForm.studentsType" @change="selectItem" clearable placeholder="请选择">
          <el-option :value="1" label="主要负责人" />
          <el-option :value="2" label="管理人员" />
          <el-option :value="3" label="从业人员" />
        </el-select>
      </el-form-item>
      <el-form-item label="课程类型" prop="courseType" v-if="!selectTF">
        <el-select v-model="dataForm.courseType" clearable placeholder="请选择">
          <el-option :value="1" v-show="dataForm.studentsType==1" label="主要负责人新取证" />
          <el-option :value="2" v-show="dataForm.studentsType==1" label="主要负责人继续教育" />
          <el-option :value="3" v-show="dataForm.studentsType==2" label="管理人员新取证" />
          <el-option :value="4" v-show="dataForm.studentsType==2" label="管理人员继续教育" />
          <el-option :value="5" v-show="dataForm.studentsType==3" label="从业人员新取证" />
          <el-option :value="6" v-show="dataForm.studentsType==3" label="从业人员继续教育" />
        </el-select>
      </el-form-item>
      <el-form-item label="是否缴费" prop="gender">
        <el-select v-model="dataForm.payStatus" clearable placeholder="请选择">
          <el-option :value="0" label="未缴费" />
          <el-option :value="1" label="已缴费" />
        </el-select>
      </el-form-item>
      <el-form-item label="过期时间" v-if="dataForm.payStatus == 1" prop="expireTime">
        <el-date-picker v-model="dataForm.expireTime" style="width: 100%;" type="datetime" placeholder="选择日期" />
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button size="mini" @click="dialogFormVisible = false">取消</el-button>
      <el-button size="mini" type="primary" @click="updateData">确定</el-button>
    </div>
  </el-dialog>
</template>

<script>
  import {
    listAssociatedIndustry,
    updateAssociatedIndustry,
    createAssociatedIndustry,
    deleteAssociatedIndustry,
    typeAssociatedIndustry
  } from '@/api/associatedIndustry'
  export default {
    data() {
      return {
        selectTF: true,
        seclectType: '',
        textMap: {
          update: '编辑用户',
          create: '添加用户'
        },
        rules: {
          payStatus: [{
            required: true,
            message: '请选择',
            trigger: 'blur'
          }],
          courseType: [{
            required: true,
            message: '请选择',
            trigger: 'blur'
          }],
          studentsType: [{
            required: true,
            message: '请选择',
            trigger: 'blur'
          }],
          studentsType: [{
            required: true,
            message: '请选择',
            trigger: 'blur'
          }],
        },
        dialogStatus: '',
        dialogFormVisible: false,
        selectTF: true,
        dataForm: {
          expireTime: undefined,
        },
        courseData: []
      }
    },
    methods: {
      selectItem(type) {
        this.seclectType = type;
        console.log(this.seclectType)
      },
      updateData() {
        this.$refs['dataForm'].validate(valid => {
          if (valid) {
            this.$emit('updateData', this.dataForm)
          }
        })
      },
      open(row) {
        this.dialogFormVisible = true
      },
      close() {
        this.dialogFormVisible = false
      }
    }
  }
</script>

<style scoped>

</style>
